package com.kuwou.workobject.controller;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.toolkit.Db;
import com.kuwou.workobject.Utils.MusicCrawlerUtils;
import com.kuwou.workobject.pojo.entity.SingerList;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@RequestMapping("/test")
@Controller
public class test {

    @GetMapping("/musicTest")
    @ResponseBody
    public Map<String, Object> musicTest() throws IOException {
        HashMap<String, Object> map = new HashMap<>();
        map.put("result", true);
        map.put("msg", "梅菜扣肉肉 - 晴天：https://lw-sycdn.kuwo.cn/e0873cb09918ed9c967f9492059f977f/68983bba/resource/30106/trackmedia/C2000049sA4r494sZH.m4a?from=vip");
        return map;
//        String searchUrl = "https://www.2t58.com/so/晴天.html";
//        String chromeDriverPath = "C:\\Program Files\\Google\\Chrome\\Application\\chromedriver.exe";
//        return MusicCrawlerUtils.crawlMusicInfo(searchUrl, chromeDriverPath);
    }

    @RequestMapping("/test")
    @ResponseBody
    public List<SingerList> test(String singerName){
        LambdaQueryWrapper<SingerList> queryWrapper =new LambdaQueryWrapper<SingerList>()
                .setEntityClass(SingerList.class)
                .like(SingerList::getSingerName, singerName);
        System.out.println(singerName);
        return Db.list(queryWrapper);
    }

    @RequestMapping("/start")
    public String start(String singerName){
        return "test";
    }
}
